package org.lex.pci.ch02;

import java.util.List;

import org.lex.pci.ch02.RecommendEngine.Match;
import org.lex.pci.ch02.RecommendEngine.Recommendation;
import org.lex.pci.ch02.data.Preferences;
import org.lex.pci.ch02.data.Users;
import org.lex.pci.ch02.similarity.EuclideanDistanceSimilarityAlgorithm;
import org.lex.pci.ch02.similarity.PearsonSimilarityAlgorithm;
import org.lex.pci.ch02.similarity.SimilarityAlgorithm;

public class RecommendEngineTest {
	public static void main(String[] args) {
		testGetRecommendations();
	}

	public static void testTopMathes() {
		RecommendEngine main = new RecommendEngine();
		SimilarityAlgorithm[] das = new SimilarityAlgorithm[] { new PearsonSimilarityAlgorithm(),
				new EuclideanDistanceSimilarityAlgorithm() };
		for (SimilarityAlgorithm a : das) {
			System.out.println("=============" + a.getName() + "=============");
			List<Match> matches = main.getTopMatches(Preferences.getInstance(), Users.TOBY, 3, a);
			for (Match m : matches) {
				System.out.println(m);
			}
		}
	}

	public static void testGetRecommendations() {
		RecommendEngine main = new RecommendEngine();
		SimilarityAlgorithm[] das = new SimilarityAlgorithm[] { new PearsonSimilarityAlgorithm(),
				new EuclideanDistanceSimilarityAlgorithm() };
		for (SimilarityAlgorithm a : das) {
			System.out.println("=============" + a.getName() + "=============");
			List<Recommendation> matches = main.getRecommendations(Preferences.getInstance(), Users.TOBY, a);
			for (Recommendation m : matches) {
				System.out.println(m);
			}
		}
	}

}
